import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'
import type { DataExportAO } from '/@/model/cn/core/tool/ao/DataExportAO'

import expressionOutputService from '/@/api/cn/core/kpis/expressionOutputService'

import type { ExpressionOutput } from '/@/model/cn/core/kpis/eo/ExpressionOutput'
import type { ExpressionOutputQO } from '/@/model/cn/core/kpis/qo/ExpressionOutputQO'
import type { ExpressionOutputVO } from '/@/model/cn/core/kpis/vo/ExpressionOutputVO'

interface ExpressionOutputState {
}

export const useExpressionOutputStore = defineStore({
  id: 'expressionOutput',
  state: (): ExpressionOutputState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<ExpressionOutput>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.save(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<ExpressionOutput>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.saveBatch(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<ExpressionOutput>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.update(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<ExpressionOutput>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.updateBatch(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<ExpressionOutput>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.remove(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<ExpressionOutput>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.removeBatch(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<ExpressionOutputQO>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.count(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<ExpressionOutputQO>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.pk(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<ExpressionOutputQO>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.query(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<ExpressionOutputQO>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.paging(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<ExpressionOutputQO>): Promise<Res<ExpressionOutputVO>> {
      return new Promise<Res<ExpressionOutputVO>>((resolve, reject) => {
        expressionOutputService.countVo(param).then((res: AxiosResponse<Res<ExpressionOutputVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<ExpressionOutputQO>): Promise<Res<ExpressionOutputVO>> {
      return new Promise<Res<ExpressionOutputVO>>((resolve, reject) => {
        expressionOutputService.pkVo(param).then((res: AxiosResponse<Res<ExpressionOutputVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<ExpressionOutputQO>): Promise<Res<ExpressionOutputVO>> {
      return new Promise<Res<ExpressionOutputVO>>((resolve, reject) => {
        expressionOutputService.queryVo(param).then((res: AxiosResponse<Res<ExpressionOutputVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<ExpressionOutputQO>): Promise<Res<ExpressionOutputVO>> {
      return new Promise<Res<ExpressionOutputVO>>((resolve, reject) => {
        expressionOutputService.pagingVo(param).then((res: AxiosResponse<Res<ExpressionOutputVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataImport(param: Param<string>): Promise<Res<ExpressionOutput>> {
      return new Promise<Res<ExpressionOutput>>((resolve, reject) => {
        expressionOutputService.dataImport(param).then((res: AxiosResponse<Res<ExpressionOutput>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataExport(param: Param<DataExportAO<ExpressionOutputQO>>): Promise<Res<string>> {
      return new Promise<Res<string>>((resolve, reject) => {
        expressionOutputService.dataExport(param).then((res: AxiosResponse<Res<string>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useExpressionOutputStoreWithout() {
  return useExpressionOutputStore(store)
}
